package hxg.作业.数据结构;

import java.util.Stack;

/**
 * @author HeXiangGuang
 * @create 2023-01-05 12:57
 */
public class Demo {
    public static void main(String[] args) {
        String str = "({({(({()}})}{())}";
        Stack<Object> stack = new Stack<>();
        int num = 0;
        int num2 = 0;
        for (int i = 0; i < str.length(); i++) {
            num2++;
            char c = str.charAt(i);
            char b = '{';
            //判断是否符合要求
            if (c==b){
                //入栈
                stack.push(i);
                //统计元素的个数
                num++;
                //出栈
                stack.pop();
            }
        }
        System.out.println(num);
    }
}
